package com.itsite.guider.demo

import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import com.itsite.guider.demo.demo.*

class MainActivity : AppCompatActivity(), View.OnClickListener {
    private var btSimple: Button? = null
    private var btNext: Button? = null
    private var btTogether: Button? = null
    private var btList: Button? = null
    private var btFragment: Button? = null
    private var btAny: Button? = null
    private var btCombination: Button? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        initView()
        initData()
    }

    private fun initView() {
        btSimple = findViewById<View>(R.id.bt_simple) as Button
        btNext = findViewById<View>(R.id.bt_next) as Button
        btTogether = findViewById<View>(R.id.bt_together) as Button
        btList = findViewById<View>(R.id.bt_list) as Button
        btFragment = findViewById<View>(R.id.bt_fragment) as Button
        btAny = findViewById<View>(R.id.bt_any) as Button
        btCombination = findViewById<View>(R.id.bt_combination) as Button
    }

    private fun initData() {
        btSimple!!.setOnClickListener(this)
        btNext!!.setOnClickListener(this)
        btTogether!!.setOnClickListener(this)
        btList!!.setOnClickListener(this)
        btFragment!!.setOnClickListener(this)
        btAny!!.setOnClickListener(this)
        btCombination!!.setOnClickListener(this)
    }

    override fun onClick(view: View) {
        when (view.id) {
            R.id.bt_simple -> startActivity(Intent(this, SimpleActivity::class.java))
            R.id.bt_next -> startActivity(Intent(this, NextActivity::class.java))
            R.id.bt_together -> startActivity(Intent(this, TogetherActivity::class.java))
            R.id.bt_list -> startActivity(Intent(this, ListActivity::class.java))
            R.id.bt_fragment -> startActivity(Intent(this, FragmentActivity::class.java))
            R.id.bt_any -> startActivity(Intent(this, AnywhereActivity::class.java))
            R.id.bt_combination -> startActivity(Intent(this, CombinationActivity::class.java))
            else -> {
            }
        }
    }

    companion object {
        private const val TAG = "MainActivity"
    }
}